package com.ljs.controller;

import com.ljs.respository.AdminMapper;
import com.ljs.service.AdminService;
import com.ljs.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@RequestMapping("/account")
public class AccountHaddler {
    @Resource
    AdminService adminService;
    @Resource
    UserService userService;
    @RequestMapping("/login/{username}/{password}/{type}")
    @ResponseBody
    public Object login(@PathVariable("username") String username,@PathVariable("password") String password ,@PathVariable("type") String type){
       //根据type的值来判断返回的对象
        Object account=null;
        System.out.println("类型是"+type);
        if(type.equals("admin")){

            account=adminService.loginAdmin(username,password);
            System.out.println("fegin用户"+account);
        }else  if(type.equals("user")){
            account=userService.loginUser(username,password);
            System.out.println("fegin用户"+account);
        }


        return  account;
    }
    }


